package mobile.android.Hotel;

import java.util.ArrayList;


import mobile.android.Hotel.R;
import mobile.android.Hotel.ExpandableListAdapter;
import mobile.android.Hotel.Hotel;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;

public class HotelActivity extends Activity {
	 private ExpandableListAdapter adapter;
	 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        ExpandableListView listView = (ExpandableListView) findViewById(R.id.listView);
        adapter = new ExpandableListAdapter(this, new ArrayList<String>(),
                new ArrayList<ArrayList<Hotel>>());
        //adapter.adGroup();

        // Set this blank adapter to the list view
        listView.setAdapter(adapter);
        //ArrayList<Hotel> ht=getUsers();
        BaseFeedParser parser = new BaseFeedParser();
        ArrayList<Hotel> ht = parser.parse();

		/** Get result from MyXMLHandler SitlesList Object */
	
        for (int i = 0; i < ht.size(); i++) {
        	Hotel hotel = ht.get(i);
        	adapter.addItem(hotel);
        }
                
        listView.setOnChildClickListener(new OnChildClickListener()
        {
            
            @Override
            public boolean onChildClick(ExpandableListView arg0, View arg1, int arg2, int arg3, long arg4)
            {	
            	
            	Hotel ht = (Hotel) adapter.getChild(arg2, arg3);
            	Intent i = new Intent("HotelInfoActivity");
            	i.putExtra("name", ht.getName());
            	i.putExtra("add", ht.getAdd());
            	i.putExtra("phone", ht.getPhone());
            	i.putExtra("web", ht.getWeb());
            	i.putExtra("logo", ht.getLogo());

            	startActivity(i);
            	
                return false;
            }
        });
            }
    
}